package gamagora.game.entity.player
{
	import gamagora.game.resources.OSSounds;
	
	import org.flixel.FlxG;

	public class OSPlayerSounds
	{
		public static const ON_STONE:uint = 0;
		public static const ON_GROUND:uint = 1;
		public static const ON_WATER:uint = 2;
		public static const ON_WOOD:uint = 3;
		
		private static const TIME_BEFORE_STEP_SOUND:Number = 0.57;
		
		private var _player:OSPlayer;
		private var _currentSound:uint;
		private var _soundTimer:Number;
		
		public function OSPlayerSounds(player:OSPlayer)
		{
			_player = player;
			_currentSound = ON_STONE;
			_soundTimer = 0;
		}
		
		public function update(): void
		{
			if(_soundTimer > TIME_BEFORE_STEP_SOUND)
			{
				if(_player.curAnim.name == OSPlayerAnimation.RUN)
				{
					switch(_currentSound)	
					{
						case ON_STONE:
							OSSounds.playPlayerStoneStep();
							break;
						case ON_GROUND:
							OSSounds.playPlayerGroundStep();
							break;
						case ON_WATER:
							OSSounds.playPlayerWaterStep();
							break;
						case ON_WOOD:
							OSSounds.playPlayerWoodStep();
							break;
					}
					_soundTimer = 0;
				}
			}
			else
			{
				_soundTimer += FlxG.elapsed;
			}
		}

		public function get currentSound():uint
		{
			return _currentSound;
		}

		public function set currentSound(value:uint):void
		{
			_currentSound = value;
		}

	}
}